﻿using com.nm.models;

namespace com.nm.interfaces
{
    public interface IFactory { }

    public interface IUserFactory : IFactory
    {
        /// <summary>
        /// 登陆系统
        /// </summary>
        /// <param name="loginName">登陆名、电话、邮件</param>
        /// <param name="pass">密码（MD5）</param>
        User Login(string loginName, string pass);

        User Login(string loginName, string pass, string pass2, string ip, int forceLogin);

        User Login(string loginName, string userId, string token, string ip);

        void LoginOut(string userid, string token, string ip);

        /// <summary>
        /// 退出登陆
        /// </summary>
        void LoginOut();

        /// <summary>
        /// 执行登陆操作
        /// </summary>
        /// <param name="user"></param>
        void DoLogin(User user);

        /// <summary>
        /// 获取用户的 刷新Token
        /// </summary>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        string GetRefreshToken(User loginUser);

        /// <summary>
        /// 根据刷新Token获取用户ID
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        int GetUserIdFromRefres(string key);

        /// <summary>
		/// 从OpenID获取用户ID
		/// </summary>
		/// <param name="openId"></param>
		/// <param name="ThirdPart">第三方类型
		/// 3 - 微信
		/// </param>
		/// <returns></returns>
		int GetUserIdByOpenId(string openId, int ThirdPart);

        /// <summary>
        /// 从用户ID获取OpenId
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="ThirdPart">第三方类型
        /// 3 - 微信
        /// </param>
        /// <returns></returns>
        string GetOpenIdByUserId(int userId, int ThirdPart);

        /// <summary>
        /// 通过用户ID获取用户
        /// </summary>
        /// <param name="cusId"></param>
        /// <returns></returns>
        User GetUserByUserID(int cusId);

        /// <summary>
        /// 通过用户的OpenID获取用户
        /// </summary>
        /// <param name="openId"></param>
        /// <param name="ThirdPart"></param>
        /// <returns></returns>
        User GetUserByOpenId(string openId, int ThirdPart);
    }
}